<?php

namespace app\admin\controller;

use app\admin\common\Common;
use app\admin\model\NotesModel;
use think\Db;
use think\exception\DbException;
use think\Request;

class Notes extends LoginThere
{
    public function index(){
        try {
            $listnotes = Db::name('notes')
                ->alias('n')
                ->join('app a', 'a.appid = n.appid')
                ->field('n.*,a.appname')
                ->paginate(10);
        } catch (DbException $e) {
            return Common::result(400,$e);
        }
        $page = $listnotes->render();
        return $this->fetch('/notes/index', ['list' => $listnotes, 'page' => $page]);
    }

    public function searchnotes(Request $request){
        $data = $request->post();
        if (empty($data['id'])){
            return Common::result(400,"请输入完整");
        }
        return NotesModel::searchnotes($data);
    }

    public function delnotes(Request $request){
        $data = $request->post();
        return NotesModel::delnotes($data);
    }



}